package com.base.lock;

/**
 * @Author HBZ
 * @Date 2020/9/28 17:30
 * @Description
 */
public class MyLockTest {
    static int count = 0;
    static MyLock lock = new MyLock();

    public static void main(String[] args) throws InterruptedException {

        for (int i = 0; i < 1000; i++) {
            new Thread(() -> {

                for (int n = 0; n < 100; n++) {
                    lock.lock();
                    try {
                        count++;
                    } finally {
                        lock.unlock();
                    }
                }

            }).start();
        }
        Thread.sleep(2000);
        System.out.println(count);
    }
}
